package Test;
import java.util.Date;
import java.util.List;

import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import pojo.Customer;
import service.CustomerManager;
import service.impl.CustomerManagerImpl;
public class TestManager {
	static  CustomerManager manager;

	@Before
	public void setUp() throws Exception {
		ApplicationContext context=new ClassPathXmlApplicationContext("applicationContext.xml");
		manager = context.getBean(CustomerManager.class);
	}
	
	@Test
	public void testAdd() {
		Customer c = new Customer(null, "ariel", 22, true, new Date());
		Customer m= manager.addCustomer(c);
		Assert.assertTrue(m!=null);
	}

	@Test
	public void testDeleteCustomer() {
		Customer m = manager.deleteCustomer("c58f2ade-e959-4fe5-8d80-eeffdd9e7313");
		Assert.assertTrue(m!=null);
	}

	@Test
	public void testUpdateGoods() {
		Customer customer=new Customer("c3acea16-e316-4d19-9ea5-fa3f37afad16","anne",30,false,new Date());
		Customer m = manager.updateCustomer(customer);
		Assert.assertTrue(m!=null);
	}

	@Test
	public void testFindAll() {
		List<Customer> customers = manager.findAllCustomers();
		Assert.assertTrue(!customers.isEmpty());
	}

}
